using CfgTable;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_BuyIconItem : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_BuyIconItem
        {
            #region ObjectBinding Generate
            public IQIGame.Onigao.Framework.ExArtSpriteNum qualityLine { protected set; get; }
            public IQIGame.Onigao.Framework.ExImage icon { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textname { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textNum { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExArtSpriteNum>("qualityLine", out var __tbv0);
                this.qualityLine = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("icon", out var __tbv1);
                this.icon = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textname", out var __tbv2);
                this.textname = __tbv2;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textNum", out var __tbv3);
                this.textNum = __tbv3;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields



        #endregion fields

        #region properties

        protected UIB_UIN_BuyIconItem ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;

        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_BuyIconItem();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {

        }

        #region methonds

        public void Show(int itemCid, int itemNum)
        {
            this.Show();
            CfgItem cfgItem = TableCenter.item.Get(itemCid);
            this.ui.textname.text = cfgItem.Name;
            this.ui.textNum.text = string.Format(APIMall.ItemNumStyle, itemNum);
            this.ui.qualityLine.SetInt(cfgItem.Quality);
            this.SetImageSprite(this.ui.icon, cfgItem.Icon_fullPath);
        }

        #endregion methonds
    }
}
